//
//  StatusDetailFrame.m
//  CC
//
//  Created by Calvin on 5/18/15.
//  Copyright (c) 2015 Calvin. All rights reserved.
//

#import "StatusDetailFrame.h"
#import "StatusOriginalFrame.h"
#import "StatusRetweetedFrame.h"
#import "StatusModel.h"

@interface StatusDetailFrame()
@property (nonatomic,assign) CGFloat tempHeight;
@end

@implementation StatusDetailFrame
-(void)setStatus:(StatusModel *)status
{
    _status = status;
    [self setupStatusOriginalFrame];
    [self setupStatusRetweetedFrameWithStatus:status];
    [self setupDetailFrame];
}

-(void)setupStatusOriginalFrame
{
    StatusOriginalFrame *originaleFrame = [[StatusOriginalFrame alloc] init];
    originaleFrame.status =self.status;
    self.originalFrame=originaleFrame;
}

-(void)setupStatusRetweetedFrameWithStatus:(StatusModel *)status
{
    if (status.retweeted_status) {
        StatusRetweetedFrame *retweetedFrame =[[StatusRetweetedFrame alloc] init];
        retweetedFrame.retweeted_status=status.retweeted_status;
        self.retweetedFrame =retweetedFrame;
        CGRect frame = retweetedFrame.frame;
        frame.origin.y=CGRectGetMaxY(self.originalFrame.frame);
        retweetedFrame.frame=frame;
        self.tempHeight=CGRectGetMaxY(self.retweetedFrame.frame);
    }
    else
    {
        self.tempHeight = CGRectGetMaxX(self.originalFrame.frame);
    }
}

-(void)setupDetailFrame
{
    CGFloat x= 0;
    CGFloat y =StatusCellMargin ;
    CGFloat w = ScreenW;
    CGFloat h =self.tempHeight;
    self.frame=CGRectMake(x, y, w, h);
}
@end
